var pageii = null;

var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id"
		},{
			colkey : "applyPeopleId",
			name : "部门"
		},{
			colkey : "fileId",
			name : "档案种类"
		},{
			colkey : "equipmentNo",
			name : "设备编号"
		},{
			colkey : "equipmentName",
			name : "设备名称"
		},{
			colkey : "reason",
			name : "维修原因"
		},{
			colkey : "sendOut",
			name : "维修申请"
		},{
			colkey : "beginTime",
			name : "维修开始时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
		}
		}
		,{
			colkey : "endTime",
			name : "维修结束时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
		}
		},{
			colkey : "repairPeople",
			name : "维修员"
		},{
			colkey : "repairResult",
			name : "维修结果"
		
		},{
			colkey : "resultConfirm",
			name : "维修结果确认"
		
		},{
			colkey : "confirmPeopleId",
			name : "确认人"
		
		},{
			colkey : "confirmTime",
			name : "确认时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
		}
		},{
			colkey : "cost",
			name : "维修费用"
		
		},{
			colkey : "remark",
			name : "备注"
		},{
			colkey : "status",
			name : "状态"
		},{
			colkey : "operation",
			name : "操作"
		},],
		jsonUrl : rootPath + '/equip/equip_repairappByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	

	$("#editFun").click("click", function() {
		editAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});


function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "编辑订单",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/equip/repair_edit.shtml?id=' + cbox
	});
}
function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/equip/repairapp_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
}



	
